<template>
  <nav class="navbar">
    <div class="container">
      <router-link to="/" class="logo">
        <h1>端午文化</h1>
      </router-link>
      <ul class="nav-links">
        <li><router-link to="/">首页</router-link></li>
        <li><router-link to="/about">端午节</router-link></li>
        <li><router-link to="/events">活动</router-link></li>
        <li><router-link to="/recipes">美食</router-link></li>
        <li><router-link to="/shop">购物</router-link></li>
        <li><ShoppingCart /></li>
      </ul>
      <div class="hamburger" @click="toggleMenu">
        <div class="line"></div>
        <div class="line"></div>
        <div class="line"></div>
      </div>
    </div>
  </nav>
</template>

<script>
import ShoppingCart from './ShoppingCart.vue'

export default {
  name: 'Navbar',
  components: {
    ShoppingCart
  },
  methods: {
    toggleMenu() {
      const navLinks = document.querySelector('.nav-links')
      navLinks.classList.toggle('active')
    }
  }
}
</script>

<style scoped>
.navbar {
  background-color: var(--primary-color);
  padding: 20px 0;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo h1 {
  color: var(--light-color);
  font-family: 'Ma Shan Zheng', cursive;
  font-size: 2rem;
  margin: 0;
}

.nav-links {
  display: flex;
  list-style: none;
  align-items: center;
}

.nav-links li {
  margin-left: 30px;
}

.nav-links a {
  color: var(--light-color);
  font-weight: 500;
  position: relative;
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 0;
  width: 0;
  height: 2px;
  background-color: var(--secondary-color);
  transition: width 0.3s ease;
}

.nav-links a:hover::after,
.nav-links a.router-link-exact-active::after {
  width: 100%;
}

.hamburger {
  display: none;
  cursor: pointer;
}

.hamburger .line {
  width: 25px;
  height: 3px;
  background-color: var(--light-color);
  margin: 5px;
  transition: all 0.3s ease;
}

@media (max-width: 768px) {
  .hamburger {
    display: block;
  }
  
  .nav-links {
    position: absolute;
    top: 80px;
    left: 0;
    width: 100%;
    background-color: var(--primary-color);
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
    clip-path: circle(0px at 90% -10%);
    transition: all 0.5s ease-out;
  }
  
  .nav-links.active {
    clip-path: circle(1000px at 90% -10%);
  }
  
  .nav-links li {
    margin: 15px 0;
  }
}
</style>